<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition template="/templates/templateListar.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions">

	<ui:define name="conteudo">
		<ui:param name="actionBean" value="#{movimentacaoMB}" />
		<h:form id="frm">

			<p:hotkey bind="esc"
				handler="document.getElementById('frmTab:btnCancelar').click()" />

		</h:form>

		<h:form id="frmTab">
			<p:commandButton id="btnCancelar" action="#{movimentacaoMB.sair}"
				immediate="true" style="display:none" value="cancelar" />
			<p:commandButton actionListener="#{movimentacaoMB.abrirModal}"
				ajax="true" title="Incluir" update=":dialogCadastro,:frmDialogMovimentacao"
				value="Novo Registro" style="float:left" icon="ui-icon-disk"
				oncomplete="dialogCadastroMovimentacao.show()">
				<f:param name="modooperacao" value="INCLUIR" />
			</p:commandButton>
			<p:dataTable id="tabela" var="item" value="#{movimentacaoMB.lista}"
				paginatorPosition="bottom" paginator="true" rows="10"
				emptyMessage="Não há registros"
				paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
				currentPageReportTemplate="(Página: {currentPage}/{totalPages})"
				rowsPerPageTemplate="10,15,25,50,100" selectionMode="single"
				rowKey="#{item.codigo}">
				<f:facet name="header">Movimentações de Produto
					
				</f:facet>
				<p:column headerText="Código" sortBy="#{item.codigo}">
					<h:outputText value="#{item.codigo}" />
				</p:column>
				<p:column headerText="Data" sortBy="#{item.data}">

					<h:outputText value="#{item.data}">
						<f:convertDateTime pattern="dd/MM/yyyy" timeZone="GMT-3"></f:convertDateTime>
					</h:outputText>

				</p:column>

				<p:column headerText="Hora" sortBy="#{item.hora}">

					<h:outputText value="#{item.hora}" converter="horaConverter" />

				</p:column>

				<p:column headerText="Usuário" sortBy="#{item.usuario.nome}">

					<h:outputText value="#{item.usuario.nome}" />

				</p:column>

				<p:column headerText="Produto" sortBy="#{item.produto.descricao}"
					filterBy="#{item.produto.descricao}" filterMatchMode="contains">

					<h:outputText value="#{item.produto.descricao}" />

				</p:column>


				<p:column headerText="Tipo Movimentação"
					sortBy="#{item.status.descricao}"
					filterBy="#{item.status.descricao}" filterMatchMode="contains">
					<h:outputText value="#{item.status.descricao}" />
				</p:column>


				<p:column headerText="Ações" style="text-align:center">

					<p:commandButton actionListener="#{movimentacaoMB.abrirModal}"
						styleClass="styleBotao" icon="ui-icon-search" title="Consultar"
						update=":dialogCadastro" ajax="true"
						oncomplete="dialogCadastroMovimentacao.show()">
						<f:setPropertyActionListener value="#{item.clone()}"
							target="#{movimentacaoMB.movimentacaoSelecionado}" />
						<f:param name="modooperacao" value="CONSULTAR" />
					</p:commandButton>


				</p:column>

				<f:facet name="footer">
					<p:outputLabel value="Total de " />
					<p:outputLabel
						value="#{fn:length(movimentacaoMB.lista)} registro(s)" />

				</f:facet>

			</p:dataTable>

		</h:form>

		<ui:include src="dialogCadastroMovimentacao.xhtml" />
		<ui:include src="/includes/confirmacaoExcluir.xhtml" />
	</ui:define>
</ui:composition>

